package query

import com.alipay.api.AlipayClient
import com.trjcn.wxpay.service.WXPayService
import config.{AliPayProperties, WXPayProperties}
import dto.req.QueryOrderReqDTO
import factory.{ActionFactory, QueryAction}
import org.slf4j.LoggerFactory
import utils.AssertUtils

abstract class BaseQueryAction extends QueryAction{

  protected val log = LoggerFactory.getLogger(this.getClass)

  protected var alipayClient:AlipayClient = null

  protected var aliPayProperties:AliPayProperties = null

  protected var wxPayProperties:WXPayProperties = null

  protected var wxPayService:WXPayService = null


  override def setProperties(bizCode: String): Unit = {
    aliPayProperties = ActionFactory.getAliPayProperties(bizCode)
    wxPayProperties =ActionFactory.getWXPayProperties(bizCode)
    wxPayService = wxPayProperties.getWXPayService
    alipayClient = aliPayProperties.getAlipayClient
  }

  override def checkParams[T <: QueryOrderReqDTO](req: T): Unit = {
    AssertUtils.notNull(req)
    AssertUtils.notNull(req.getPayChannel, "payChannel 支付渠道不能为空")
    AssertUtils.notNull(req.getPayOrderNo, "payOrderNo 支付订单号不能为空")
    AssertUtils.notNull(req.getTxType, "txType 交易类型不能为空")
  }
}
